@extends('layout.home.master')
@section('content')
    <div class="container mt-4">
        <div class="row mt-2">
            <div class="col-9">
                <div class="card card-body p-5">
                    <div class="row">
                        <div class="col text-right">
                            @if($article->isFavorite(auth()->user()))
                                <a href="{{route('common.favorite.click',['model'=>'Article','id'=>$article->id])}}"
                                   class="btn btn-white btn-sm"> <span class="fe fe-calendar"
                                                                       style="color: goldenrod;"></span>️
                                    取消收藏</a>
                            @else
                                <a href="{{route('common.favorite.click',['model'=>'Article','id'=>$article->id])}}"
                                   class="btn btn-white btn-sm"> <span class="fe fe-star"
                                                                       style="color: orangered;"></span>️
                                    收藏</a>
                            @endif

                        </div>
                    </div>
                    <div class="row">
                        <div class="col text-center">
                            <!-- Title -->
                            <h2 class="mb-3">
                                {{$article->title}}
                            </h2>
                            <p class="card-text small text-muted">
                                <span class="fe fe-user "></span>{{$article->user->name}}<span
                                        class="fe fe-clock ml-3"></span>
                                {{$article->created_at->diffForHumans()}}
                            </p>
                        </div>
                    </div> <!-- / .row -->
                    <hr>
                    <div class="content mt-3">
                        {!! $article->content !!}
                        <hr>
                        <div class="text-center">
                            @if($article->isZan(auth()->user()))
                                <a href="{{route('common.zan.click',['model'=>'Article','id'=>$article['id']])}}" class="btn btn-warning"><span class="fe fe-thumbs-up "></span>取消赞</a>

                            @else
                                <a href="{{route('common.zan.click',['model'=>'Article','id'=>$article['id']])}}" class="btn btn-info"><span class="fe fe-thumbs-up "></span>点个赞呗</a>
                            @endif
                        </div>
                    </div>

                    <div style="overflow: hidden;width: 100%">
                        @foreach($article->zan()->with('user')->get() as $user)
                            <div class="avatar " style="float: left;margin-right: 10px; margin-top: 10px">
                                <img src="{{$user->user->icon}}" alt="..." class="avatar-img rounded-circle">
                            </div>
                        @endforeach
                    </div>

                </div>
                @include('layout.comment.master',['model'=>$article])
            </div>

            <div class="col-sm-3">
                <div class="card">
                    <div class="card-header">
                        {{$article->user->name}}
                    </div>
                    <div class="card-body text-center">
                        <div class="avatar avatar-xl">
                            <a href="{{route('info.user.show',$article->user)}}"><img src="{{$article->user->icon}}" alt="..." class="avatar-img rounded-circle"></a>
                        </div>
                    </div>
                    @can('isSub',$article->user)
                        <div class="card-footer">
                            @if(auth()->user()->isfollower($article->user))
                                <a href="{{route('info.ToggleFollower',$article->user)}}"
                                   class="btn btn-danger btn-block">取消关注</a>
                            @else
                                <a href="{{route('info.ToggleFollower',$article->user)}}"
                                   class="btn btn-white btn-block">关注</a>
                            @endif
                        </div>
                    @endcan

                </div>
            </div>
        </div>
    </div>


@endsection
